import Vue from 'vue'
import Vuex from 'vuex'
import {mapState} from 'vuex'

Vue.use(Vuex);
const mutations= {
  increment (state,n) {
    state.count = n
  },
  getuserInformation(state,n){
    state.userInformation=n
  }
}
const computed=mapState({
  // 箭头函数可使代码更简练
  count: state => state.count ,  // es6写法，function (state) { return state.count }
  userInformation: state => state.userInformation
})

export default new Vuex.Store({
  name: 'store',
  state: {
    count: null,
    userInformation:null
  },
  mutations,
  computed
})

